<?php ob_start();?>
<!doctype html>
<html>
<?php 
	$root = $_SERVER['DOCUMENT_ROOT'];
 	include($root.'/standart/head.php');
 	include($root.'/standart/dateHeader.php');
 	include($root.'/standart/dbconnect.php');
 	$db = connect();
?>
<?php
session_start();
if(isset($_COOKIE['tzRemember'])){
	$_SESSION['id'] = $_COOKIE["gevezeUser"];
	$_SESSION['usr'] = $_COOKIE["gevezeMail"];
}
if(isset($_GET['logoff']))
{
	$_SESSION = array();
	session_destroy();
	setcookie("tzRemember","", time() -3600);
	setcookie("gevezeMail","", time() -3600);
	setcookie("gevezeUser","", time() -3600);
	header("Location: order-list.php");
	exit;
	
}

?>
<head>
<meta charset="utf-8">
<title>Geveze Cafe | Kayıt</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--Google Fonts-->
<link href='http://fonts.googleapis.com/css?family=Oswald|Lato|Roboto:400,500,700|Open+Sans:600,700,300' rel='stylesheet' type='text/css'>
<!--Custom Css-->
<link href="css/custom.css" rel="stylesheet" type="text/css">
<!--Colors Css-->
<link href="css/colors_3.css" rel="stylesheet" type="text/css">

<!--Boostrap Css-->
 <!--<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">--> 
<link href="css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="css/table.css" rel="stylesheet" type="text/css"> 

<link href="css/sb-admin.css" rel="stylesheet">
<!--Boostrap-Responsice Css-->
<link href="css/bootstrap-responsive.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap-modal.css" rel="stylesheet" type="text/css">
<!--Calender Css-->
<link rel='stylesheet' type='text/css' href='css/fullcalendar.css' />
<!--Awesome Fonts-->
<link href="css/font-awesome.css" rel="stylesheet">
<!--Banner Slider-->
<link rel="stylesheet" href="css/flexslider.css" type="text/css" media="screen" />
<!--Scrollbar Css-->
<link href="css/jquery.mCustomScrollbar.css" rel="stylesheet" />
<!--Pie Chart Css-->
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen">
<link rel="stylesheet" type="text/css" href="css/slide.css" media="screen" />
<link href="css/tinyBox.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="css/jquery-ui-1.10.4.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
<link href="css/dates.css" rel="stylesheet">

<!--Date Picker-->
<link href="css/datepicker3.css" rel="stylesheet">
<!-- Html5 Js -->
<script src="js/html5.js" type="text/javascript"></script>

<script type="text/javascript">
	function loadPage() {
		listOrders();
	}
	function listOrders(){

		var myCookie = document.cookie.replace(/(?:(?:^|.*;\s*)gevezeUser\s*\=\s*([^;]*).*$)|^.*$/, "$1");

		url = 'getOrdersOfUser.php?report=1'
			+'&begin_date='+$("#order_bgn_date").val()
			+'&end_date='+$("#order_end_date").val()
			+'&user_id='+myCookie;
		//+'&user_id='+$("#search_user_id").val();
		$('.table-responsive').html(ajx(url, ''));
		var table = $('#dataTables-example').dataTable({
            "language": {
                "url": "css/plugins/dataTables/dataTablesTurkish.json"
            },
			"footerCallback": function ( row, data, start, end, display ) {
	            var api = this.api();
	            // Remove the formatting to get integer data for summation
	            var intVal = function ( i ) {
	                return typeof i === 'string' ?
	                    i.replace(/[\$,]/g, '')*1 :
	                    typeof i === 'number' ?
	                        i : 0;
	            };
	 
	            // Total over all pages
	            var total = api
	                .column( 7 )
	                .data()
	                .reduce( function (a, b) {
	                    return intVal(a) + intVal(b);
	                } );
	 
	            // Total over this page
	            var pageTotal = api
	                .column( 7, { page: 'current'} )
	                .data()
	                .reduce( function (a, b) {
	                    return intVal(a) + intVal(b);
	                } );
	 
	            // Update footer
// 	            $( api.column( 7 ).footer() ).html(
// 	                ''+pageTotal.toFixed(2) +'TL (Genel Toplam: '+ total.toFixed(2) +' TL)'
// 	            );
	        }
        } );

		$('#dataTables-example tbody').on( 'click', 'tr', function () {
	        if ( $(this).hasClass('selected') ) {
	            $(this).removeClass('selected');
	        }else {
		        if(table.$('tr.selected') != null){
	        		table.$('tr.selected').removeClass('selected');
		        }
	            $(this).addClass('selected');
	            row = $(this).find("td");
	            url = 'getOrdersFe.php?report=1'
					+'&order_id='+row[0].innerText;
				$('.table-responsive_2').html(ajx(url, ''));
				$('#dataTables-example_2').dataTable({
		            "language": {
		                "url": "css/plugins/dataTables/dataTablesTurkish.json"
		            }
		        } );
	            }});

		$(function () {
			var currentDate = new Date();
			$("#order_bgn_date").datepicker({
				  	endDate: currentDate,
				    language: "tr",
				    autoclose: true
				    //format: 'yyyy/m/d',
				    //daysOfWeekDisabled: "0,6",
					
			  });
       
        
			$("#order_end_date").datepicker({
					//startDate : currentDate,
				    language: "tr",
				    autoclose: true,
				    todayHighlight: true
				    //format: 'yyyy/m/d',
				    //daysOfWeekDisabled: "0,6",
			  });

		 });
		 $('#dataTables-example_2_wrapper').remove();
		        
	}
	
  	</script>
</head>

<body onload="loadPage()">

<div id="toppanel">
	<div id="panel">
		<div class="content clearfix">
	        <?php
			if(!$_SESSION['id']):
			header("Location: index.php");
			exit;
			?>
			<div class="right">
				<!-- Login Form -->
				<form class="clearfix" action="" method="post" id="loginForm">
					<a style="cursor: pointer; right: 0px; float: right; line-height: 12px;" href="register.php">Kayıt Ol</a>
					<table style="border: none; width: 100%;">
						<tr>
							<td>
								<input type="hidden" value="add-address.php" name="pageName">
								<input class="field" type="text" name="username" id="username" value="" size="23" placeholder="E-Mail"/>
							</td>
							<td>
								<input class="field" type="password" name="password" id="password" size="23" placeholder="Şifre" />
							</td>
							<td>
								<a style="cursor: pointer;" onclick="forgetPass()">Şifremi Unuttum</a>
							</td>
						</tr>
						<tr>
							<td>
								<label><input name="rememberMe" id="rememberMe" type="checkbox" checked="checked" value="1" /> &nbsp;Beni hatırla</label>
							</td>
							<td colspan="2">
								<input type="button" name="submit" value="Giriş" class="bt_register" onclick="sendData()" />
							</td>
						</tr>
					</table>
				</form>
			</div>
            <?php
			
			else:
			
			?>            
            <div class="right">
            	<input class="btn btn-danger btn-xl" type="button" style="cursor: pointer; right: 0px; float: right; line-height: 12px; padding-right:30px; padding-left:30px;" onclick="window.location.replace('?logoff')" value="Çıkış"/>
            	<div class="loginTop"><?php echo $_SESSION['usr'] ? 'Merhaba '.$_SESSION['usr'] : '';?> <br/></div>
	            <div class="loginMenu">
	            	<div class="loginMenuLeft" onclick="window.location.replace('order-list.php')"> Siparişlerim </div>
	            	<div class="loginMenuMid" onclick="window.location.replace('user-info-change.php')"> Kişisel Bilgilerim </div>
	            	<div class="loginMenuMid" onclick="window.location.replace('add-address.php')"> Adres Ekle</div>
	            	<div class="loginMenuRight" onclick="window.location.replace('change-password.php')"> Şifre Değiştir </div>
	            </div>
            </div>
            <?php
			endif;
			?>
		</div>
	</div> <!-- /login -->	

    <!-- The tab on top -->	
	<div class="tab">
		<ul class="login">
	    	<li class="left">&nbsp;</li>
	        <li id="toggle">
				<a id="open" class="open" href="#"><?php echo $_SESSION['id']?'Kullanıcı Bilgileri':'Üye Girişi | Yeni Üye';?></a>
				<a id="close" style="display: none;" class="closex" href="#">Bilgi Alanını Kapat</a>			
			</li>
	    	<li class="right">&nbsp;</li>
		</ul> 
	</div> <!-- / top -->
</div> <!--panel -->

<!--Wrapper Start-->
<div id="wrapper"> 
  <!--Header Start-->
<header id="header"> <!--<span class="icon-dish"></span>-->
    <div class="container">
      <div class="row-fluid">
        <div class="span3">
          <div class="logo"><a href="index.php"><img src="images/logo-gevezecafe.png" alt="img"></a></div>
        </div>
        <div class="span8 margin-non">
          <div class="top-container">
            <div class="span5"></div>
            <div class="span7">
             </div>
          </div>
          <div class="navbar navbar-inverse nav-bar">
            <div class="navbar-inner nav-bar-inner">
              <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
              <div class="nav-collapse collapse top-nav">
                <ul class="nav">
                  <li class="dropdown"> <a class="dropdown-toggle" href="index.php">ANA SAYFA</a>
                  </li>
                  <li class="dropdown"> <a class="dropdown-toggle" href="menu.php" >MENÜ</a>
                  </li>
                  <li class="dropdown"> <a class="dropdown-toggle" href="cart.php" >SEPETİM</a>
                  </li>
				  <li class="dropdown"> <a class="dropdown-toggle" href="about.php" >HAKKIMIZDA</a>
                  </li>
                  <li class="dropdown"> <a class="dropdown-toggle" href="contact.php" >İLETİŞİM</a></li>
                </ul>
              </div>
              <!--/.nav-collapse --> 
            </div>
            <!-- /.navbar-inner --> 
          </div>
          <!--Nav End--> 
        </div>
      </div>
    </div>
  </header>
  <!--Header End--> 
  
  <!--Banner Start-->
  <section id="banner" class="height">
    <div class="contact-banner"><img src="images/1600x182.jpg" alt="img"></div>
  </section>
  <!--Banner End-->
    <section id="content" class="container"> 
    <!--Blog Page Section Start-->


  <!--Content Area Start-->
  <section id="content" class="container"> 
    <section class="blog-page-section">
      <div class="row-fluid">
        <div class="span12">
          <div class="heading">
            <h1 style="font-family: helvatica;">Sipariş Bilgileri</h1>
          </div>
        </div>        
      </div>
    </section>
    
    <!--Form Section Start-->
    <!-- /.row -->
            <div class="row">
                <!-- /.col-lg-12 -->
                <div class="col-lg-12">
                	<div class="panel panel-default">
                        <div class="panel-body">
                        	<div class="row">
                                <div class="col-lg-12">
                                	<div class="frm-group" style="float: left; margin-right: 20px;">
										<label style="margin-top: 7px;">Başlangıç Tarihi</label>
									</div>
                                	<div class="frm-group" style="float: left;  margin-right: 20px;">
                                        <input type="text" class="frm-control datepicker" id="order_bgn_date" style="height: 30px;">
									</div>
                                	<div class="frm-group" style="float: left;  margin-right: 20px;">
										<label style="margin-top: 7px;">Bitiş Tarihi</label>
									</div>
                                	<div class="frm-group" style="float: left;  margin-right: 20px;">
                                        <input type="text" class="frm-control datepicker" id="order_end_date" style="height: 30px;">
									</div>
                                	<button type="button" id="btnGetHtml" class="btn btn-default" onclick="listOrders()">Listele</button>
                                </div>
                            </div>
                        	<div class="table-responsive">
                            </div>
                            <div class="panel panel-default">
                            <div class="panel-body">
                            <div class="table-responsive_2">
                            </div>
                            </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 
            <div class="row">
				<div class="col-lg-6" style="height: 450px;">
		            <iframe frameborder="0" class="frame" src="" id="container"></iframe>
				</div>
			</div>  -->
            <!-- /.row -->
    <!--Form Section End--> 
  </section>
  <!--Content Area End--> 
</section>
          
          
 
  <!--Footer Area Start-->
  <footer id="footer">
    <div class="row-fluid">
      <section class="footer-section-1">
        <div class="bg-opacity-2">
          <div class="container">
            <div class="span3">
              <div class="featured-dishes">
                <h4>Sizin İçin Seçtiklerimiz</h4>
				<ul>
				<?php
				
				$featuredQuery ="SELECT * FROM MENU WHERE ID IN (SELECT MENU_ID FROM MENU_FEATURE WHERE ISFEATURED='E')";
				$featuredMenuList = $db->query($featuredQuery) or die($featuredQuery."<br/><br/>".mysql_error());
				$rows = 0;
				while($featuredMenu = $featuredMenuList->fetch_assoc()){
					if(is_null($featuredMenu['PICTURE'])){
						$menuImg = "images/featured-footer-img-1.jpg";
					}
					else{
						$menuImg = $featuredMenu['PICTURE'];
					}
				?>
					<li>
						<div class="frame"><img src="<?php echo $menuImg; ?>" style="width: 113px; height: 50px;" alt="img"></div>
						<div class="text"> <strong class="title"><?php echo $featuredMenu['PRODUCT_NAME'];?></strong> </div>
					</li>
				<?php
					$rows++;
					if($rows==3){
						break;
					}
				}
				disconnect($db);
				?>
				</ul>
              </div>
            </div>
            <div class="span1">
            </div>
			<div class="span2">
              <div class="recent-post">
                <div class="featured-dishes">
                  <h4>Site Haritası</h4>
                  <ul>
                    <li class="site-map">
                      <div id="address" class="recent-post-text"> <strong class="title"><a href="index.php">Ana Sayfa</a></strong></div>
                    </li>
                    <li class="site-map">
                      <div id="address" class="recent-post-text"> <strong class="title"><a href="menu.php">Menü</a></strong></div>
                    </li>
                    <li class="site-map">
                      <div id="address" class="recent-post-text"> <strong class="title"><a href="cart.php">Sepetim</a></strong></div>
                    </li>
                    <li class="site-map">
                      <div id="address" class="recent-post-text"> <strong class="title"><a href="about.php">Hakkımızda</a></strong></div>
                    </li>
                    <li class="site-map">
                      <div id="address" class="recent-post-text"> <strong class="title"><a href="contact.html">İletişim</a></strong></div>
                    </li>
                  </ul>
                </div>
              </div>
            </div> 			
            <div class="span3">
              <div class="recent-post">
                <div class="featured-dishes">
                  <h4>Adres</h4>
                  <ul>
                    <li>
                      <div id="address" class="recent-post-text"> <strong class="title">IYTE Teknopark, Gülbahçe<br/>Urla İzmir</strong> </div>
                    </li>
                    <li>
                      <div id="phone" class="recent-post-text"> <strong class="title">Telefon: 0232 765 90 95<br/></strong> </div>
                    </li>
                    <li>
                      <div id="email" class="recent-post-text"> <strong class="title">Email: info@gevezecafe.com</strong> </div>
                    </li>
                  </ul>
                </div>
              </div>
            </div>           
            <div class="span3">
              <div class="watch-box">
                <div class="watch-img"> <img src="images/watch-img.png" alt="img">
                  <div class="time-box"> <strong class="time">Hafta İçi Her Gün</strong> <strong class="time">08:00 - 19:00</strong> </div>
                </div>
                <strong class="book-table">Siparişleriniz İçin: <span class="red">0232 765 9095</span></strong> 
              </div>
            </div>
          </div>
        </div>
      </section>
      <!--Footer Section Section 3 Start-->
      <section class="footer-section-3">
        <div class="container">
          <div class="span6">
            <div class="copy-section"><strong class="copy">&copy; 2014 Teknopark Geveze Cafe, Designed by <a href="http://gevezecafe.com/" class="link" target="_blank">gevezecafe.com</a></strong></div>
          </div>
          <div class="span6">
            <div class="footer-social-box">
              <ul>
                <li class="social-icon-1"><a href="#">p</a></li>
                <li class="social-icon-2"><a href="#">twitter</a></li>
                <li class="social-icon-3"><a href="#">facebook</a></li>
                <li class="social-icon-4"><a href="#">facebook</a></li>
                <li class="social-icon-5"><a href="#">facebook</a></li>
                <li class="social-icon-6"><a href="#">facebook</a></li>
              </ul>
            </div>
          </div>
        </div>
      </section>
      <!--Footer Section Section 3 End--> 
    </div>
  </footer>
  <!--Footer Area End--> 
  <p id="back-top"> <a href="#top" class="back-top">Back to Top</a> </p>
</div>   
<div id="invisDiv" style="display: none;"></div>
<!-- jQuery --> 
<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script><!-- jQuery lib Js --> 
<script type="text/javascript" src="js/jquery-ui-1.10.4.js"></script>

<!-- Bootstrap --> 
<script src="js/bootstrap.min.js" type="text/javascript"></script><!-- Boostrap Js --> 
<script src="js/bootstrap-modal.js" type="text/javascript"></script>
<script src="js/bootstrap-modalmanager.js" type="text/javascript"></script>

<!-- FlexSlider --> 
<script defer src="js/jquery.flexslider.js"></script><!-- FlexSlider --> 

<!-- Custom Scripts --> 
<script src="js/custom.js" type="text/javascript"></script><!-- Custom Scripts --> 

<script src="js/jquery.maskedinput.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/tinybox.js"></script>
<script type="text/javascript" src="js/login.js"></script>
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/plugins/dataTables/jquery.dataTables.js"></script>
<script type="text/javascript" src="js/plugins/dataTables/dataTables.bootstrap.js"></script>

<!--Moment JS -->
<script src="js/moment.js"></script>
<script src="js/moment-with-locales.js"></script>

<!--Date Picker Js--> 
<script src="js/bootstrap-datepicker.js"></script><!--Date Picker Js--> 
<script src="locales/bootstrap-datepicker.tr.js"></script><!--Date Picker Js--> 
<!--Wrapper End-->
</body>
</html>
<?php ob_flush(); ?>